<template>
  <view class="start">

              <image
            class="logo"
            src="https://dmn000001-1301065476.cos.ap-guangzhou.myqcloud.com/sas/apple/rentou.png"
            mode="widthFix"></image>

        <view class="br">

        <input class="input" style="margin-top: 70rpx;"   v-model="userInput1" placeholder-style="color:#fff" placeholder="请输入主题，如牛肉"
         :style="{ 'background-image': 'url(' + EnumBG.BU3 + ')' }" />

         <input class="input"  v-model="userInput2" placeholder-style="color:#fff" placeholder="请输入动作，如不能吃"
         :style="{ 'background-image': 'url(' + EnumBG.BU3 + ')' }" />


        <input class="input"  v-model="userInput3" placeholder-style="color:#fff" placeholder="请输入结果，熟可以吃"
         :style="{ 'background-image': 'url(' + EnumBG.BU3 + ')' }" />

        <view class="mr-commit" @click="commit" :class="sizeStatus ? 'mr-commit-big'
         : 'mr-commit-small'" :style="{ 'background-image': 'url(' + EnumBG.BU4 + ')' }">
        观看广告查询</view>
        <LandscapeModel v-model:show="show" :sonFun="sonFun"/>


        </view>
  </view>
</template>

<script setup lang="ts">
import LandscapeModel from "@/components/Landscape/LandscapeModel.vue";
import { EnumStatus } from "@/utils/constants";
import { marketing } from "@/utils/ab";
import { EnumBG } from "@/utils/content";
import dyUserPlayingService from "@/api/dyUserPlayingService";
const sizeStatus = ref(false)
const show = ref(false)
const emit = defineEmits(['update:defStatus','update:content'])
const userInput1 = ref()
const userInput2 = ref()
const userInput3 = ref()

const sonFun = async()=>{
     const data = await marketing(userInput1.value,userInput2.value,userInput3.value)

    emit('update:defStatus',EnumStatus.RESULT)
    emit('update:content',data)
}

const w = async(str:string)=>{
  const {result}  = await dyUserPlayingService.sensitiveWord({word:str})
    if(result){
        uni.hideLoading()
        uni.showToast({
            title: '存在敏感词,请重新填写',
            duration: 2000,
            icon:"none"
        });
        return true
    }
    return false
}

const startTimer = () => {
    setInterval(() => {
        sizeStatus.value =  !sizeStatus.value
    }, 1000); // 每秒执行一次
  };

  const commit =async ()=>{
    if(!userInput1.value || !userInput2.value || !userInput3.value){
        uni.showToast({
        title: "不能为空",
        duration: 2000,
        icon:"none"
      });
      return
    }
  if( await w(userInput1.value ) ||  await w(userInput2.value ) ||  await w(userInput3.value )){
    return
  }

    show.value = true
}



onMounted(()=>{
      startTimer()
  })
</script>

<style lang="scss" scoped>
.start{

    .br{
        width: 80%;
        height: 800rpx;
        position: absolute;
        left: 10%;
        top: 20%;   
        background-size: 100% 100%;
        background-repeat: no-repeat;
        // display: flex;
        // align-items: center;
        // justify-content: center;
        background-image: url("https://dmn000001-1301065476.cos.ap-guangzhou.myqcloud.com/sas/apple/biankuang.png");
    }
    .logo{
             position: absolute;
             top: 40%;   
             left: 35%;
            width: 240rpx;
            height: 240rpx;
        }

    .mr-commit{
      z-index: 102;
      width: 46%;
      height: 130rpx;
      margin-left: 27%;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      color: white;
  }
  .mr-commit-big{
      width: 50%;
      height: 150rpx;
      margin-left: 25%;
      transition: all 1s;
  }
  .mr-commit-small{
      width: 46%;
      height: 130rpx;
      margin-left: 27%;
      transition: all 1s;
  }
    
    .input{
        width: 70%;   
        padding: 20rpx;
        margin: 50rpx 15%;
        height: 10%;
        background-size: 100% 100%;
        z-index: 10;
        color: white;
        text-align: center;
        } 
}

</style>
